package com.example.hrsystem.data.source;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
import androidx.room.Delete;

import com.example.hrsystem.workflow.model.ProcessInstance;

import java.util.List;

@Dao
public interface ProcessInstanceDao {
    @Query("SELECT * FROM process_instances")
    List<ProcessInstance> getAllProcessInstances();

    @Query("SELECT * FROM process_instances WHERE id = :id")
    ProcessInstance getProcessInstanceById(int id);

    @Query("SELECT * FROM process_instances WHERE processDefinitionId = :processDefinitionId")
    List<ProcessInstance> getProcessInstancesByDefinitionId(int processDefinitionId);

    @Query("SELECT * FROM process_instances WHERE initiatorId = :initiatorId")
    List<ProcessInstance> getProcessInstancesByInitiatorId(int initiatorId);

    @Query("SELECT * FROM process_instances WHERE status = :status")
    List<ProcessInstance> getProcessInstancesByStatus(String status);

    @Insert
    void insertProcessInstance(ProcessInstance processInstance);

    @Update
    void updateProcessInstance(ProcessInstance processInstance);

    @Delete
    void deleteProcessInstance(ProcessInstance processInstance);

    @Query("DELETE FROM process_instances")
    void deleteAllProcessInstances();
}